﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SVN.Net.Misc.FileWriter
{
    public class LocalFileWriter:IFileWriter
    {
        #region IFileWriter Members

        public void Write(string fileName, string code)
        {
            if (System.IO.File.Exists(fileName))
            {
                System.IO.FileStream fs = null;
                System.IO.StreamWriter sw = null;
                try
                {
                    fs = System.IO.File.Open(fileName, System.IO.FileMode.Truncate, System.IO.FileAccess.Write);
                    sw = new System.IO.StreamWriter(fs);
                    sw.Write(code);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    if (sw != null)
                        sw.Close();
                    if (fs != null)
                        fs.Close();
                }
            }
        }

        #endregion
    }
}
